package com.china08.yxyapi.api.manage.tec.office.cla;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.mg.office.YxyNoticeClass;
import com.china08.yxyapi.model.YxyApiPageReqModel;
import com.china08.yxyapi.repository.mg.YxyNoticeClassRepository;

import io.swagger.annotations.ApiOperation;

@CrossOrigin
@RestController
public class TecOfficeClaDelController extends YxyApiBaseController {
    @Autowired
    YxyNoticeClassRepository yxyNoticeClassRepository;

    @ApiOperation("删除通知")
    @RequestMapping(value = "/api_yw/manage/tec/office/cla/del", method = RequestMethod.POST)
    public void precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
        String id = reqModel.id;
        YxyNoticeClass yxyNoticeClass = yxyNoticeClassRepository.findById(id);
        if (yxyNoticeClass != null) {
            yxyNoticeClassRepository.delete(yxyNoticeClass);
        }
    }

    public static class ReqModel extends YxyApiPageReqModel {
        public String id;

        @Override
        public void autoCheck() {
            Assert.isTrue(StringUtils.isNotBlank(id), "删除通知不能为空");
        }
    }
}
